<?php
include('libary/init_index.php');
$curdir=getcwd();
chdir('/home/cailuong/public_html/beta/template/forum/');
require_once('./global.php');
$GLOBALS['user']=$vbulletin->userinfo['userid'];
chdir($curdir);
 if ($_POST['album_name']=='') header('location:/'); else
 {
	 $name=$_POST['album_name'];
	 $artist=$_POST['album_artist'];
	 $author=$_POST['album_author'];
	 $cat=$_POST['album_cat'];
	 $info=$_POST['album_info'];
	 $curdir=getcwd();
	 chdir('/home/cailuong/public_html/beta/data/upload/fd8543acb46544ff94e40e4a957550cd/');
	 $fdir=md5($GLOBALS['user']).'/';
	 $tdir='queue/';
	 $file=scandir($fdir);	 
	 foreach ($file as $value) if (($value!='.')&&($value!='..')){
		 $filename=$value;
		 $ext=substr($value,strlen($value)-3,3);
		 if ($ext=='MP3') $ext='mp3';
		 $num=rand(1,10000000);
$link='data/upload/fd8543acb46544ff94e40e4a957550cd/'.$tdir.$GLOBALS['user'].'-'.time().$num.'.'.$ext;
		 rename($fdir.$value,$tdir.$GLOBALS['user'].'-'.time().$num.'.'.$ext);
		 $cmd="INSERT INTO `tmp` VALUES ('','".$name."','".$artist."','".$author."',".$cat.",'".$info."','".$filename."','".$link."',".$GLOBALS['user'].",".time().")";
		@mysql_query($cmd);
	 }
	 chdir($curdir);  
	 $_POST['album_name']='';	 
	 echo '
	 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>UPLOAD THÀNH CÔNG</title>
</head>
<body>
	 <script type="text/javascript" >
	 function delayer(){
     window.location = "/"; 
     }
	 alert(" Cám ơn bạn đã đóng góp album '.$name.'. Ngay sau khi kiểm duyệt, chúng tôi sẽ thông báo đến bạn và đăng tải lên trang chủ để chia sẻ với tất cả mọi người. Ban Quản Trị !");
	 window.setTimeout(delayer(),0);
	 </script>
</body>
</html>
	 ';
 }
?>